Run through shellcheck.net. Converted all printf to echo since it's easier, may convert back later if given good reason.