Fix Various bugs, remove all unused debug statements