code clean + bugfixes