Fixed code structure to be in line with architecture and added functionality.
Merge origin/master