Adding significant performance speed up with using buffering on output, still not 100% up to my taste yet