Removed unneeded redeclare
Cleaned up code.
Added missing each, reformulated for OpenModelica.
Added regularization