Redone some of the fixes and removed debug output