API: Move stats update for API module execution to when the module is actually executed