Fix various nil cases
Refactor routes
Various fixes and refacto