Bug fixes

Fixes #38
Fixes #39