FIX: fixed rules overflow bugs, factorized exit code in new ST_END state. All tests passing now.