small changes on the data structure and cleaning up