incorporate some suggestions from @yzl

Thanks!