Add type hints in performance-critical areas