Added doc blocks and other minor tweaks
Minor refactoring