Move typedefs at top
Remove unused code