Fixes to JS code to ensure record numbering/loading consistency