fixes and better logging