improved logging; also outputs to file