Fixes #10 and other small bugfixes