Added loader and cleaned up the JS a bit