moved internal use functions to internal.c, and implemented some performance enhancements
implemented test for buf_splice()