Modifications for exceptions and memory management.