 					{
 						loc.returnValue = loc.returnValue & "/" & loc.property; // add hard coded param from route
 					}
-				}		
+				}
 			}
 		}
 		else
 		{
 			// link based on controller/action/key
-			if (!Len(arguments.controller) && !Len(arguments.action))
-				arguments.action = variables.params.action; // when no controller or action was passed in we link to the current page (controller/action only, not query string etc) by default
-			if (!Len(arguments.controller))
-				arguments.controller = variables.params.controller; // use the current controller as the default when none was passed in by the developer
+			if (!Len(arguments.controller) && !Len(arguments.action) && structkeyexists(loc.params, "action"))
+				arguments.action = loc.params.action; // when no controller or action was passed in we link to the current page (controller/action only, not query string etc) by default
+			if (!Len(arguments.controller) && structkeyexists(loc.params, "controller"))
+				arguments.controller = loc.params.controller; // use the current controller as the default when none was passed in by the developer
 			loc.returnValue = loc.returnValue & "?controller=" & REReplace(REReplace(arguments.controller, "([A-Z])", "-\l\1", "all"), "^-", "", "one");
 			if (Len(arguments.action))
 				loc.returnValue = loc.returnValue & "&action=" & REReplace(REReplace(arguments.action, "([A-Z])", "-\l\1", "all"), "^-", "", "one");

			loc.returnValue = loc.returnValue & $constructParams(arguments.params);
		if (Len(arguments.anchor))
			loc.returnValue = loc.returnValue & "##" & arguments.anchor;
				
		if (!arguments.onlyPath)
		{
			if (arguments.port != 0)

	<cfargument name="port" type="numeric" required="false" default="#application.wheels.functions.URLFor.port#" hint="Set this to override the current port number">
	<cfscript>
		var loc = {};
		loc.params = {};
		if (structkeyexists(variables, "params"))
			structappend(loc.params, variables.params, true);
		if (application.wheels.environment != "production")
		{
			if (arguments.onlyPath && (Len(arguments.host) || Len(arguments.protocol)))
