Some refactoring, and implementes setHandlePositions.