Some refactoring lets hope nothing is broken