bugfixes, refactors