Fix Mac python packaging and clean up code