Added some diagnostic logging