Refactoring of move-history code