Added a more robust way of instantiating.