Fixed hang and removed debug code