Tested with a submodule and fixed a few problems