Major refactor; add support for multiple packages.