Large impl reworking (nearly from scratch); improved API.