Migrating to Swift (almost done, still not injecting JS properly)