Bit refactoring
More partial refactoring + output source
Move config to own file, misc refactoring