Refactor internal APIs, improve naming, add constraints on routes and fix few bugs