Implement local min and max functions
Cleanup