Slightly rough, but possibly working version.