reorganizing stuff, adding some comments