Port to C11 aligned_alloc, and fix some integer overflows.