Fixed bugs&typos, added test cases, debugging 4 small n