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!