Moved types out of the main file, moved util functions.