Fixed arrays to throw out of bounds exception if the index is out of bounds. Added proper array C++ interop. Changed arrays to be always in memory. Factored out exception throwing mechanism.