Added more logging and removed some old deprecated code (which was actually commented out).