Fixed a few issues in api helper script