Fix several issues

Fixes #8 and #13