Move more functionality from play and stop scripts into the base for use elsewhere