Runtime: Fixed bug in apply_array() for cyclic arrays. Also unifies the two branches of apply_array().