Refactoring code

This PR aims at refactoring code removing the circular dependency due to the app.js module.