Initial JS re-organisation