more cleanups of the script, move it to contrib