Fixed some errors relating to study attachments, por files and referencecontainers in general. Did some more lucene tests