Corrected numerous bugs and added so many useless debug