code cleanup and even more logging