imporoved code readability. Improved JavaScript design

Used designs from The Good Parts and Design Patterns to improved TOAD
overall design.