Performance improvements for position calc

Several times speedup for swap position calc.