Make this work for both Python 2 and 3, remove trailing whitespace