Almost working version.