some bugfixes & refaktoring