Changed some Javascript around, added a little more functionality