Moved UUID saving to the gate itself, and added some null checking