First pass at thread safety. Add test for clearHistory().