Factored out some functions to ASimulator