Huge refactoring to support multiple package types