Add some handlers and fix some bugs.