Massive rework of index file.

Trying to condense the code as necessary and remove the ugly design, over-modularization, and straight "dumbass" problems in the code.
(finish? really? wtf is that even doing...and that json encode function! wtf?!)