Figure out maxRecords more robustly

Fixes #17