Added check for main function to all classes where needed.