Various fixes to whitespace transformer

@zpao