This makes it possible to switch to a more efficient map type without changing all occurences manually. Merges half of #4413.
Also changes mempool to store CTxMemPoolEntries to keep track of when they enter/exit the pool.