Fixed various array issues