Fixed last bugs, now it passes 100% of test cases provided by the professor.