Split API classes and interfaces

Split previous API files into many more classes and interfaces. Manager and Server APIs were left as-is.

It may be helpful to create a class hierarchy/diagram.
As discussed, I left `$flags` an integer and added constants for the wire protocol flags.