clone from https://bitbucket.org/mamburu/cog/src/