main module cleaning:
 * deleted unused functions
 * refactored anonymous function expressions to named function expressions
 * added apache licence preamble
 * refactoring
 * JSHint