some code cleanup and docblock