Part of the manager API is implemented, and works correctly.

Some code clean up.