Small style fixes and close some file handle.