Fixed bug with object creation in constructor