second batch of code cleanup+comments