 		}
 
 		// return true by default (happens when no callbacks are set or none of the callbacks returned a result)
-		if (!StructKeyExists(loc, "rv"))
-		{
-			loc.rv = true;
-		}
-	</cfscript>
-	<cfreturn loc.rv>
-</cffunction>
-
-<cffunction name="$queryCallback" returntype="boolean" access="public" output="false">
-	<cfargument name="method" type="string" required="true">
-	<cfargument name="collection" type="query" required="true">
-	<cfscript>
-		var loc = {};
-
+		if (!StructKeyExists(local, "rv"))
+		{
+			local.rv = true;
+		} 
+		return local.rv;
+	}
+
+	public boolean function $queryCallback(required string method, required query collection) {
 		// we return true by default
 		// will be overridden only if the callback method returns false on one of the iterations
-		loc.rv = true;
+		local.rv = true;
 
 		// loop over all query rows and execute the callback method for each
-		loc.iEnd = arguments.collection.recordCount;
-		for (loc.i=1; loc.i <= loc.iEnd; loc.i++)
+		local.iEnd = arguments.collection.recordCount;
+		for (local.i=1; local.i <= local.iEnd; local.i++)
 		{
 			// get the values in the current query row so that we can pass them in as arguments to the callback method
-			loc.invokeArgs = {};
-			loc.jEnd = ListLen(arguments.collection.columnList);
-			for (loc.j=1; loc.j <= loc.jEnd; loc.j++)
-			{
-				loc.item = ListGetAt(arguments.collection.columnList, loc.j);
+			local.invokeArgs = {};
+			local.jEnd = ListLen(arguments.collection.columnList);
+			for (local.j=1; local.j <= local.jEnd; local.j++)
+			{
+				local.item = ListGetAt(arguments.collection.columnList, local.j);
 				try
 				{
 					// coldfusion has a problem with empty strings in queries for bit types
-					loc.invokeArgs[loc.item] = arguments.collection[loc.item][loc.i];
+					local.invokeArgs[local.item] = arguments.collection[local.item][local.i];
 				}
 				catch (Any e)
 				{
-					loc.invokeArgs[loc.item] = "";
+					local.invokeArgs[local.item] = "";
 				}
 			}
 
 			// execute the callback method
-			loc.result = $invoke(method=arguments.method, invokeArgs=loc.invokeArgs);
-
-			if (StructKeyExists(loc, "result"))
-			{
-				if (IsStruct(loc.result))
+			local.result = $invoke(method=arguments.method, invokeArgs=local.invokeArgs);
+
+			if (StructKeyExists(local, "result"))
+			{
+				if (IsStruct(local.result))
 				{
 					// the arguments struct was returned so we need to add the changed values to the query row
-					for (loc.key in loc.result)
+					for (local.key in local.result)
 					{
 						// add a new column to the query if a value was passed back for a column that did not exist originally
-						if (!ListFindNoCase(arguments.collection.columnList, loc.key))
+						if (!ListFindNoCase(arguments.collection.columnList, local.key))
 						{
-							QueryAddColumn(arguments.collection, loc.key, ArrayNew(1));
+							QueryAddColumn(arguments.collection, local.key, ArrayNew(1));
 						}
-						arguments.collection[loc.key][loc.i] = loc.result[loc.key];
+						arguments.collection[local.key][local.i] = local.result[local.key];
 					}
 				}
-				else if (IsBoolean(loc.result) && !loc.result)
+				else if (IsBoolean(local.result) && !local.result)
 				{
 					// break the loop and return false if the callback returned false
-					loc.rv = false;
+					local.rv = false;
 					break;
 				}
 			}
 		}
 
 		// update the request with a hash of the query if it changed so that we can find it with pagination
-		loc.querykey = $hashedKey(arguments.collection);
-		if (!StructKeyExists(request.wheels, loc.querykey))
-		{
-			request.wheels[loc.querykey] = variables.wheels.class.modelName;
-		}
-	</cfscript>
-	<cfreturn loc.rv>
-</cffunction>+		local.querykey = $hashedKey(arguments.collection);
+		if (!StructKeyExists(request.wheels, local.querykey))
+		{
+			request.wheels[local.querykey] = variables.wheels.class.modelName;
+		}	
+		return local.rv;
+	}
+</cfscript>
<!--- PUBLIC MODEL INITIALIZATION METHODS --->

<cffunction name="afterCreate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterCreate", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterDelete" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterDelete", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterFind" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterFind", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterInitialization" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterInitialization", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterNew" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterNew", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterSave" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterSave", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterUpdate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterUpdate", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterValidation" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterValidation", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterValidationOnCreate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterValidationOnCreate", argumentCollection=arguments)>
</cffunction>

<cffunction name="afterValidationOnUpdate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="afterValidationOnUpdate", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeCreate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeCreate", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeDelete" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeDelete", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeSave" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeSave", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeUpdate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeUpdate", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeValidation" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeValidation", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeValidationOnCreate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeValidationOnCreate", argumentCollection=arguments)>
</cffunction>

<cffunction name="beforeValidationOnUpdate" returntype="void" access="public" output="false">
	<cfargument name="methods" type="string" required="false" default="">
	<cfset $registerCallback(type="beforeValidationOnUpdate", argumentCollection=arguments)>
</cffunction>

<!--- PRIVATE METHODS --->

<cffunction name="$registerCallback" returntype="void" access="public" output="false">
	<cfargument name="type" type="string" required="true">
	<cfargument name="methods" type="string" required="true">
	<cfscript>
		var loc = {};

		// create this type in the array if it doesn't already exist
		if (!StructKeyExists(variables.wheels.class.callbacks,arguments.type))
		{
			variables.wheels.class.callbacks[arguments.type] = ArrayNew(1);
		}

		loc.existingCallbacks = ArrayToList(variables.wheels.class.callbacks[arguments.type]);
		if (StructKeyExists(arguments, "method"))
		{
			arguments.methods = arguments.method;
		}
		arguments.methods = $listClean(arguments.methods);
		loc.iEnd = ListLen(arguments.methods);
		for (loc.i=1; loc.i <= loc.iEnd; loc.i++)
		{
			if (!ListFindNoCase(loc.existingCallbacks, ListGetAt(arguments.methods, loc.i)))
			{
				ArrayAppend(variables.wheels.class.callbacks[arguments.type], ListGetAt(arguments.methods, loc.i));
			}
		}
	</cfscript>
</cffunction>

<cffunction name="$clearCallbacks" returntype="void" access="public" output="false">
	<cfargument name="type" type="string" required="false" default="">
	<cfscript>
		var loc = {};
		arguments.type = $listClean(list="#arguments.type#", returnAs="array");

		// no type(s) was passed in. get all the callback types registered

		}

		// loop through each callback type and clear it
		local.iEnd = ArrayLen(arguments.type);
		for (local.i=1; local.i <= local.iEnd; local.i++)
		{
			variables.wheels.class.callbacks[arguments.type[local.i]] = [];
		} 
	}

	public any function $callbacks(string type="") { 
		if (Len(arguments.type))
		{
			if (StructKeyExists(variables.wheels.class.callbacks, arguments.type))
			{
				local.rv = variables.wheels.class.callbacks[arguments.type];
			}
			else
			{
				local.rv = ArrayNew(1);
			}
		}
		else
		{
			local.rv = variables.wheels.class.callbacks;
		} 
		return local.rv;
	}

	public boolean function $callback(
		required string type,
		required boolean execute,
		any collection=""
	) { 
		if (arguments.execute)
		{
			// get all callbacks for the type and loop through them all until the end or one of them returns false
			local.callbacks = $callbacks(arguments.type);
			local.iEnd = ArrayLen(local.callbacks);
			for (local.i=1; local.i <= local.iEnd; local.i++)
			{
				local.method = local.callbacks[local.i];
				if (arguments.type == "afterFind")
				{
					// since this is an afterFind callback we need to handle it differently
					if (IsQuery(arguments.collection))
					{
						local.rv = $queryCallback(method=local.method, collection=arguments.collection);
					}
					else
					{
						local.invokeArgs = properties();
						local.rv = $invoke(method=local.method, invokeArgs=local.invokeArgs);
						if (StructKeyExists(local, "rv") && IsStruct(local.rv))
						{
							setProperties(local.rv);
							StructDelete(local, "rv");
						}
					}
				}
				else
				{
					// this is a regular callback so just call the method
					local.rv = $invoke(method=local.method);
				}

				// break the loop if the callback returned false
				if (StructKeyExists(local, "rv") && IsBoolean(local.rv) && !local.rv)
				{
					break;
				}
