read rules from server
move redirect code to separate module
update doc comments