add cancancan for authentication and other refactorings