big refactoring, bugfixes, api cleanup, better handling flows