Fix bugs and add chat support