Finished the last piece and fixed compile errors