Finished main functions.