Factor out general utilities to own file.