fixed array representation. Started (and almost finished) cleanup