Separated toplevel functions to conform to PEP8