Fix outpath related bug and update code in docs