Code cleanup part 1