[TIMOB-10464] Bug fixes and code cleanup