Clean ups and fix for exception.