Misc changes
Added return code checking for ::close()