code cleanup + documentation