Better guard against failed redis connection attempts. Also reformat code.