Full implementation, following screencast.