Some refactoring, move functions to the right positions