Fix incorrect header package definitions parsing
Group definitions by package they are defined in