refactors code tree structure; split lots of things into new modules