Split API code off into separate file.

Nothing works still but it's more organized!