fix bugs in API/python