Cleanup and testing of AKL changes.

Added some tests and docstrings too.