restructure; bugfixes