ContextListener bug + lot of refactoring