Refactor settings

Divide files better so that some can be stored in database.