Refactoring, cleanup and add submodule