Finish main functions.