Fixes for array out of bounds