Initial version which uses less memory (and tightens up warnings)