Breaking out api, managing memory