Code cleanup, better error handling in RecordService