Fixed API crash issues