Refactored, move some settings to config