more perf improvements, fix bug where positions are doubled