Added a check if a given parameter exists before trying to cast a value to it. Fixes #2713