Improve whitespace trimming