Some bug fixes

Fixes #23 and #19