Merge "NPE and ArrayIndex exception fixes"