clean up code; more comments