-<!--- PUBLIC MODEL CLASS METHODS --->
-
-<cffunction name="average" returntype="any" access="public" output="false">
-	<cfargument name="property" type="string" required="true">
-	<cfargument name="where" type="string" required="false" default="">
-	<cfargument name="include" type="string" required="false" default="">
-	<cfargument name="distinct" type="boolean" required="false">
-	<cfargument name="parameterize" type="any" required="false">
-	<cfargument name="ifNull" type="any" required="false">
-	<cfargument name="includeSoftDeletes" type="boolean" required="false" default="false">
-	<cfargument name="group" type="string" required="false">
-	<cfscript>
-		var loc = {};
+<cfscript>
+	/*
+	* PUBLIC MODEL CLASS METHODS
+	*/
+	
+	public any function average(
+		required string property,
+		string where="",
+		string include="",
+		boolean distinct,
+		any parameterize,
+		any ifNull,
+		boolean includeSoftDeletes="false",
+		string group
+	) { 
 		$args(name="average", args=arguments);
 		arguments.type = "AVG";
 		if (StructKeyExists(arguments, "group"))
 		{
-			loc.rv = $calculate(argumentCollection=arguments);
+			local.rv = $calculate(argumentCollection=arguments);
 		}
 		else
 		{
 			if (ListFindNoCase("cf_sql_integer,cf_sql_bigint,cf_sql_smallint,cf_sql_tinyint", variables.wheels.class.properties[arguments.property].type))
 			{
 				// this is an integer column so we get all the values from the database and do the calculation in ColdFusion since we can't run a query to get the average value without type casting it
-				loc.values = findAll(select=arguments.property, where=arguments.where, include=arguments.include, parameterize=arguments.parameterize, includeSoftDeletes=arguments.includeSoftDeletes);
-				loc.values = ListToArray(Evaluate("ValueList(loc.values.#arguments.property#)"));
-				loc.rv = arguments.ifNull;
-				if (!ArrayIsEmpty(loc.values))
+				local.values = findAll(select=arguments.property, where=arguments.where, include=arguments.include, parameterize=arguments.parameterize, includeSoftDeletes=arguments.includeSoftDeletes);
+				local.values = ListToArray(Evaluate("ValueList(local.values.#arguments.property#)"));
+				local.rv = arguments.ifNull;
+				if (!ArrayIsEmpty(local.values))
 				{
 					if (arguments.distinct)
 					{
-						loc.tempValues = {};
-						loc.iEnd = ArrayLen(loc.values);
-						for (loc.i=1; loc.i <= loc.iEnd; loc.i++)
+						local.tempValues = {};
+						local.iEnd = ArrayLen(local.values);
+						for (local.i=1; local.i <= local.iEnd; local.i++)
 						{
-							StructInsert(loc.tempValues, loc.values[loc.i], loc.values[loc.i], true);
+							StructInsert(local.tempValues, local.values[local.i], local.values[local.i], true);
 						}
-						loc.values = ListToArray(StructKeyList(loc.tempValues));
+						local.values = ListToArray(StructKeyList(local.tempValues));
 					}
-					loc.rv = ArrayAvg(loc.values);
+					local.rv = ArrayAvg(local.values);
 				}
 			}
 			else
 			{
 				// if the column's type is a float or similar we can run an AVG type query since it will always return a value of the same type as the column
-				loc.rv = $calculate(argumentCollection=arguments);
+				local.rv = $calculate(argumentCollection=arguments);
 
 				// we convert the result to a string so that it is the same as what would happen if you calculate an average in ColdFusion code (like we do for integers in this function for example)
-				loc.rv = JavaCast("string", loc.rv);
-			}
-		}
-	</cfscript>
-	<cfreturn loc.rv>
-</cffunction>
-
-<cffunction name="count" returntype="any" access="public" output="false">
-	<cfargument name="where" type="string" required="false" default="">
-	<cfargument name="include" type="string" required="false" default="">
-	<cfargument name="parameterize" type="any" required="false">
-	<cfargument name="includeSoftDeletes" type="boolean" required="false" default="false">
-	<cfargument name="group" type="string" required="false">
-	<cfscript>
-		var loc = {};
+				local.rv = JavaCast("string", local.rv);
+			}
+		} 
+		return local.rv;
+	} 
+	public any function count(
+		string where="",
+		string include="",
+		any parameterize,
+		boolean includeSoftDeletes="false",
+		string group
+	) { 
 		$args(name="count", args=arguments);
 		arguments.type = "COUNT";
 		arguments.property = ListFirst(primaryKey());

		// since we don't return any records for calculation methods we want to skip the callbacks
		arguments.callbacks = false;

		loc.rv = findAll(argumentCollection=arguments);
		if (!StructKeyExists(arguments, "group"))
		{
			// when not grouping by something we just return the value itself
			loc.rv = loc.rv[loc.alias];
			if (!Len(loc.rv) && Len(arguments.ifNull))
			{
				loc.rv = arguments.ifNull;
			}
		}
	</cfscript>
	<cfreturn loc.rv>
</cffunction>
		}

		// create a list of columns for the `SELECT` clause either from regular properties on the model or calculated ones
		local.properties = "";
		local.iEnd = ListLen(arguments.property);
		for (local.i=1; local.i <= local.iEnd; local.i++)
		{
			local.item = Trim(ListGetAt(arguments.property, local.i));
			if (ListFindNoCase(variables.wheels.class.propertyList, local.item))
			{
				local.properties = ListAppend(local.properties, tableName() & "." & variables.wheels.class.properties[local.item].column);
			}
			else if (ListFindNoCase(variables.wheels.class.calculatedPropertyList, local.item))
			{
				local.properties = ListAppend(local.properties, variables.wheels.class.calculatedProperties[local.item].sql);
			}
		}
		arguments.select &= local.properties;

		// alias the result with `AS`, this means that Wheels will not try and change the string (which is why we have to add the table name above since it won't be done automatically)
		local.alias = LCase(arguments.type);
		local.alias = Replace(Replace(Replace(local.alias, "avg", "average"), "min", "minimum"), "max", "maximum");
		if (arguments.type != "count")
		{
			local.alias = arguments.property & local.alias;
		}
		arguments.select &= ") AS " & local.alias;

		if (StructKeyExists(arguments, "group"))
		{
