Code cleanup and externalization of deps into submodules