Code cleanup and doc blocks