fixed compile errors, still not tested.