Style and accuracy changes recommended by @vext01.