Fix major bug with NullPointer and ArrayOutOfBound