fixed a whole bunch of rules bugs; now seems to work