Improve management of command history