Some major revisions. Have not yet be tested.