First version, not quite finished.