Internal code cleanup