Adding support for Json Web Tokens + refactoring.