Cleanup of resources ; fixed warnings