Security features closes #24 and deduplication closes #23

The tickets #23 and #24 should largely explain what is going on in these commits.