bugfixing, cleanup