Fixes Issue #22 & #38

The first commit only fixes #22
The second has both fixes