Minor bugfixes and tweaks