RF: Made align code more general.