Fixed bug when declaring objects on a not-yet-open connection. Thanks Miron.