Fix flakes, pep8 and copyright