Refactor to preferred coding style
Add notes
Basic rule matching now works