Add attribution and tests, contain option, and minor reworking