Added cleanup code for when the cache shuts down… connections are now closed properly
Other misc tidying up