First somewhat working version.