Strip whitespace, fix references