Fix issue with invalid ref in database