Refactored Dispatcher.

To make it easier to implement dispatchers on other platforms. Currently
assuming a single dispatcher per application. Had to copy most of
NGenerics locally just to get a PriorityQueue implementation as it has
no PCL version.