Make the position calculation a bit more robust - see #300