fixing code control flow, better event handling and multi level caching
fixing server.js conflict