Mostly working code for ...