various bugfixes to the system