add support for multiple packs and fix bugs.