Bugfixes to main classes