Fix some bugs in RecordManager