Fixed merge conflicts/cleaned up code

So I tried running the stuff I was going to push to you earlier, ended up not working.  I think something went wrong in ui.js so I went back to clean up the code and now it should good to go.