Which piece are you referring to? Most of this logic is verbatim from module_edit's loadEdit method, so I didn't want to mess with it. I'm happy to add comments if you think it is unclear.