Initial skeleton, plus rough algorithm work