Various code cleanup, formatting, comments