converting GenericArray operations to template-unrolled loops
and the ternary operation
fixed a few more bugs