Improve package name parsing