A few bug fixes + refactor specifically made for my cobcide project on launchpad