Replaced bellman implementation with one that uses queues rather than re...

...cursion.