Set routes variable to object, changed some parameter checking and set v...

Comments are in the code.

Routes parameter needed to be set to an object, incorrect argument was being checked as being the callback, r was not set and should be arguments[1] (could also be set to route).

this commit fixes #1