Performance tweaks in the most inner-loops when get packages

* Uses strtol instead of the slow sscanf, this gives the biggest perf boost
* Instead of rechecking which type we got, cache the array pointer. less branching