Makes sure that internal properties do not leak onto created objects.

Fixes #5485.