Fix some bugs and Remove unused things