Move all included code into lib/ directory

This makes it easier to track which code comes from other
repositories and projects, as well as update and/or clean up
that code when necessary.

Closes #491
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>