More improvements to buildPath()

Re: @monarchdodra's review