Reorganise the directory and fix some bugs;