Removed debugging statements and cleaned up code