API rework (WIP)

THIS CODE IS NOT WORKING!!
Refactor API to integrate pieter's proposed changes
Merge pull request #2 from camspiers/pieterv-api-rework

Pieterv api rework