Fix: some bugs such as relation handling