added some additional logging and some code cleanup