more rules and bug fixes