Improved the yet another new instance factory implementation in general.

Signed-off-by: Jakob Brandsborg Ehmsen <jakobehmsen.github@gmail.com>