Fix a few bugs and add mode relaying