restructure code; add some categories