Jarv/config refactor wip

Might be worth factoring out these functions in a separate file, to be able to import them instead of copy&pasting