non-interactive mode plus minor cleanup