add better history support. clean up the implementation.

Signed-off-by: Joshua Rubin <jrubin@zvelo.com>