Moved close to finally block
Mostly formatting changes