Added a new 'replay' script to help with testin/debugging.  Various code cleanups.