Use posix_memalign and _alloc_aligned for aligned memory. Remove unused code.