Fix some bugs and add dependencies.