Rearrange functions; remove useless prototypes.