null pointer bugs fixed