Bug fixes

Fixes #21
Fixes #22