Bugfix to prevent conversion errors when closing the CF connections

Bugfix to prevent cast error when closing resources and adjacent function formatting update. See commit notes for additional details.