Bug fixes and removal of debugging