Closes #684 Signed-off-by: wm4 <wm4@nowhere> Includes some minor cosmetic changes additional to the original PR.