Fix some bugs and buglets