Cleaning up the APIWrapper. Adding command line help, version and minor code re-ordering.