bugfix (mispelled variable name) + improved functions for adding constants and state variables