Refactor and start splitting up monolithic process functions