Javascript references are really stupid