Fixed main functions.