More alignment refactoring

which uncovered a couple bugs, which were also fixed.