Under very rare conditions the sun pan was wrong for a few seconds around noon in spring and fall, because the value for acos was out of range (-1, 1).

Fixed that and updated the code in the first post.