debugging problem with API.flush