First (really) working version which supports $ParamDef