Refactor settings and connection class