main: Reorder/rename functions