code cleanup & documentation