Misc bugfixes
More misc bugfixes