Refactor a bit the grimoire code