Fix rules and rearrange - not tested