This doesn't do a complete cleanup. E.g. the D11StateBlock s aren't freed. Is this intended? If so comment why.