Cleanup and refactoring.

Centralized API in appa.go and rules.go to make it easier to find.