Complete revamp of code according to proper angular organisation