added file output, minor fixes