complex version: minor fixes, shebang corrected