Splitting the big index.js file

Hello, 
I have tried to break apart the big index.js file to make it more manageable. A lot of things have moved around, but it is a pure refactoring so new new or removed features or gui elements. Some more testing would be desirable so I haven't broken anything, but I have done some testing myself.