Modularisation

Modularising the code. Target is to achieve MVC as per best practice.