Cleaning up api code a bit.  Still a lot to do