Cleaned up generic types in newInstance (thanks @mikeb01 !)