Added ability to return used planning context, renamed 2 functions, added comments