bugfixes + removing obsolete code