Fixes #30 and other minor issues