Api fixes

Better logging and several fixes