bugfixes and organizing