Use hash table for contexts

This reduces memory leaks and makes the development model more
consistent