Improved version of string padding functions