Added some logging, cleanup some local references