Final cleanup
Added optgroup for index
Got rid of all anonymous js functions
prettified code