some fixes and additional logging