First round of refactoring. Stopped splitting the rule string over and over
Second round of refactoring. Improved method naming and readability of some code