Move definitions closer to the place where they're used.
Remove unused methods.