Every command that is run is being added to the history, not just commands that are executed via the [ALT]+! and [ALT]+| sequences. It would be better to just store the commands that the user types, and not store commands since they are often more complex.