Bugfixes and tweaks