Incorporated changes suggested by @wltrimbl, @mattphotonman and @ahmadia