Ignore leading and trailing whitespace

Need to write tests still, fixes #1306