I've noticed that the level-finished-replay doesn't function properly whenever the main character picks up the last key (thus unlocking the exit) and the shadow is in front of the exit!
Try it out on level 23 of the tutorial level pack:
1. Move your shadow in front of the exit.
2. Collect the last key.
3. Watch the level-finished-replay go wrong, because the key is missing.
This doesn't seem to occur when the main character is in front of the exit and the shadow collects the last key .
Good luck with debugging !