AMRules: Fixed voting bug.
Some code moved to Utils.
Minor fixes