tested scripts, fixed bugs #587