Fixed ensure_open bug