Random bugfixes and tweaks