few fixes and a parameter to reduce disk usage (writing to file)