Fixed more bugs and removed debug output.