Restructured coding

Restructured the code to use subdirs template and prepare code for change
to plugins