Work in progress: refactor packaging code.