Fix date range searching and do some cleanup.