added in some extra checks for API==null