fixing NPEs and compatibility issues