Fix min() deprecation and fix package issues