Refactors and documents routes