Add more null checking to completion code