Refactor request-handler and apis