api overhaul

Major restructuring of how the API works internally.