passing slices means passing by reference instead of making a copy (AFAIUnderstand)
try to optimize the memory use a bit, did not help with the weird malloc errors though