Corrected code that read and writes arrays

This makes allocations of vectors related to arrays function properly
and many more tests pass.

Currently 100%
Need to implement more tests to cover other cases.

Bit sets need some work.