Fix monitoring code