Making a start on the API.

Fixing mass of log output while I'm at it.