Removed old debug stuff and fixed a bug