the code for this was ugly (and commented as such) so did some refactoring around this fix. fix for 0.10.2cp2