Fixed bugs in S() (infinite loop) and H() (wrong results).