Rewrote to match new API.