[CAST-1773] Code improvements.
[CAST-1773] Code cleanness improvements and refactoring.