Fixed an off-by-one error and improved the inititalization, both sometimes caused access exceptions. Also prevented the program from crashing completely in that case… still probably poor design, but the best we can do loading all this unmanaged code.