Improving comments and whitespace
Moved getElement function to dom-utils

Also extracted out more nested functions, added comments, cleaned up
comments