Fix unsafe use of pickle.loads