Remove unneeded hashbang
remove dependency on globals
Get rid of print ifo logging
Refactor rules structure. Add rules state for every rule (for storing data about the rule) and a rule contex for storing the context in which rules run