Fix dead code and null pointer errors in Platform-core