Improved performance by replacing StringBuffer with StringBuilder.