Misc bug fixes

Misc stuff