Refactor in contexts
Fix imports handling and template usage