Cleaned up record/playback code. Added file auto-looping.