Fix prev() bug by rebuilding caseIDToIndexMap after new cases are added.
Implement min() and max() as aggregate functions (like mean(), median()).
prev() and next() default to undefined if no user-specified default.