Fixes #3962 - Refactor class overwriting