Sets up main functions