Adding corrections proposed by @dpshelio and @derdon