Added a test, added more comments, and fixed some memory leaks in escalate_module*.