added the ability to limit the number of history items returned
clean up and updates