Bugfixes

Fixes  #268 and some minor glitches I've found while testing other stuff.