oauth2 restructuring with database implementation and code cleanup.