Fix changing views on redirecting
Refactor and add lib directory