Api cleanup and the stuff that comes with it

@gholtslander 

Made all of the apis use functions from functions.php, so they'll be easier to reuse and write. It'll also help with my unit testing efforts coming soon!
I'll get this up on the sandbox and let you see what this looks like now :)