Fixed some constructor/deconstructor issues