Fix some bugs, closed some TODOs