Replaced response_expand with BSD-licensed reimplementation.

Cleanup to follow later.

GitHub: Fixes #267.