Fix bugs and add features