Miscellaneous fixes

Fixes issues #9 and #11, and yet unmentioned issues.