Finish porting misc changes; add prototypes for remaining functions.