Make trailing whitespace actually work and add a function for removing it.