mostly done now. Needs documentation