WIP: Schema

The idea here is to go through all the user-facing functions and organize them into 3 sections.

 1 - Declare all local variables at the top
 2 - Check the arguments against a static schema
 3 - Perform the action being aware of early exits and cleanup of resources.

There are quite a few memory leaks that are only triggered by various error cases.  This refactor should fix most if not all of them.
But they are static on the C file.  Shouldn't they match?  The use of header files at all is questionable with the current way it builds since you could never use these header files without also including the corresponding C files.

With dukluv I recently made the files actually standalone and link them together as a last step.  It made the build a little slower and exported a lot more symbols into the final object, but it made my lint tool happier.