Clean typing and bug fixes.