Some minor housekeeping
Misc bugfixes