Align.py bugfix and memory optimization