More bug fixes

This fixes #10 and #3.