Merge "Refactor handling of input records."