Split code into files and added support for storing authorization.