[TIMOB-10464] More bug fixes and code cleanup