fork from https://github.com/beartung/MoGit and some custom