Bugfixes and test mode