Safe constructor.