Bug fixes to custom rules