Updating some code to work with the new concepts of a State object and grouped goals
added a constant
corrected potential NPE