Fixed most issues with function definition.