Assertion and code cleanup

* Added an assertion for the lengths of the sequences when using
  non-mutual alignment.
* Cleaned up duplicated code.