Fix some bugs and delete garbage