update

small changes to script, various small bugs fixed.