Refactored runtime hooks