Performance issues
performance optimisations: profiling with xdebug, made string buffer, other improvements
merged Magomogo:performance