Refactor python module