Miscellaneous code cleanup part 2