Refactor snippets mechanism