Make free and document helper functions.
Add copyright and docstrings.
Factor out local calling of amp responder.