Fix sending the wrong information to the client
Javascript optimisations