Updated to use js callbacks.