Make AAtree more const-friendly, clean up code style.
Add some const constraints.
Make generator implementations subclasses of Device_impl.