Migrate to Pyone and refactor