Refactor routes and filters