Some clean up and also more logging