[TIMOB-10464] Code cleanup and bug fixes