Bugfix and tweaks