Refactored routing mechanism
Added some documentation