Added more null checks, increased the api level.