Bug fixes from Peter. Added feature to read arbitrary detector sizes.