Bug fixes and extra loggin