back to liberal mask; fix extrema calculation to minima