Bug fix to alignment producing code