case 3654 - Code corrections and more drupal way.
case 3654 - Another set of code refactor.
case 3654 - Some logic fixes and improvements.
Merge branch 'case-3654' into develop