Applied code review, added 2 new helper functions.
merge conflicts
Hotfixes after merge