Code cleanup and added support for history-only searches