lot of work on analysis and cleaning up