Added null checks and made extension class internal.