works for py3, dropped py2 support for now
trailing spaces cleaning