Fix code style and remove some unnecessary string length checks