Slightly simplify some code

There's no need to cast the union - we can just access the appropriate member
instead.
Move type declarations closer to where variables are first used

Where possible I combined them with assignments.
The entry_data.data_size member is a uint32_t, not an int or size_t
Add missing word in comment