Added swapping; corrected array system