Split simulation process into several functions.