Refactor rules editor for greater robustness & usability