more logging and a little cleanup