code corrections, array split, cleaning up