Corrected bugs after thorough testing