various code cleanup