code cleanup, prepare for #3, close #2