Remove trailing whitespace
Reduce malloc calls