Modified code to change record/playback behavior based on configuration (except for looping based on time)