Fixes for issues #27 & #29 (try #2)

Hopefully this is better...