Order out if login is cancelled
Fixed some leaks
Support newDocument:
Fixed constraints