Remove redundant tests. Prefer resize to substr for removing the tail of a string. Redundant string conversions.