Changed the align array generation algorithm so that it works correctly.