Fixed warning in close. Refined exceptions.