Performance improvements

moved some things around improved the performance of jqueery.