bug fixes, and completion of extended MDP (untested)