I made a very nice ghosting system some years back.
Simply stuff all the data in a array, which you can use to loop through at a later stage.
I used to store the ghost runs in local storage (array.asjason) and pass it to other players in a network game.
Works pretty decent, looping through it; using moveto.
The array lends itself for easily adding extra data (timing/tick, angles, sizes, etc)
You can easy tweak how much data gets stored by either passing a timed interval (every x seconds) or somewhere in the midst of your code.