Added support for automatic rest alignment.