fixes in history cleaning