First mostly working version