code cleanup, more docs