NPE and API inconsistency fixed