Big logic changes. Array support added.