Why dispose() is called twice?