You created a bug here because dataLen _includes_ the two bytes that make the dataLen (whence the peek).  Your changes cause the loop that reads the section data to read 2 bytes past the end of the section.  Most of the changes in this pull request look alright - except these ones in the newAppSec function don't particularly seem to add much other than just doing things a slightly different way.