Added some logging... and other things