Update for max() deprecation and fix package issues
Merge commit 'a8ef28452d1c7cd0f17e93bfee7ccdbf8654ac52'