Fixed loop unrolling, resolves #6