Bug fixes, debug code removed