Implement main functions.