[Client] Cleaned up code, fixed some bugs, and finished some TODOs.