restructure code to separate packages