Very rough initial working version, uses callback API.