Refactor

Refactored. Small fixes. Settings moved to main.