General fix for alignment issues on ARM

and alloc big arrays on heap instead of stack, to prevent overflow on small stack