Refactored record iteration to make it a bit simpler and slightly faster.