refactors Router and adds documentation