Done changes for compatbility & fixed some NPE's