repair swig Ternary operation and syntax errors

Swig doesn't support ternary operations with setting new variable. Apart form that there were some syntax errors.