Remove use of deprecated APIs

Also, add a spec.