Refactor the code. Add RecordPlay interface and make gui code simpler.