bunch of fixes and more cleaning