General refactoring and updates based on JSLint

Renamed SegmentArray.js to ElementArray.js
Normalized whitespace
Refactored based on JSLint