Jaggr refactoring - interim changes

This is the new branch taken from the latest master branch.
I am creating this pull request, just to confirm whether the changes are now preserved and it looks good.
The changes are not complete. I have just made a couple of changes.