update trim - remove getbytes

I re-implemented the function trim so as to be more readable and memory-friendly.
Also removed the function getbytes as I realized in C there is no need for a such function.