Changed implementation of controller to improve clarity.
Merge branch 'master' into openmodelica