Misc tweaks and bug fixes