anchor.diff:  // Update the simulation
   //-----------------------------------------------------
   function update(simulation) {
  -  updateWeather();
  -  updateSoil();
  -  updateCrops();
  +	updateWeather();
  +	updateSoil();
  +	updateCrops();
   }
   
   // Update the weather
   //-----------------------------------------------------
   function updateWeather() {
  -
  -  <%= @simulation.weather.code.html_safe %>
  -
  -  postMessage({
  -    type: 'weather_update',
  -    weather: simulation.weather
  -  });
  +	<%= @simulation.weather.code.html_safe %>
  +	postMessage({
  +		type: 'weather_update',
  +		weather: simulation.weather
  +	});
   }
   
   // Update the soil
   //-----------------------------------------------------
   function updateSoil() {
  -  for(x = 0; x < simulation.width; x++) {
  -    for(y = 0; y < simulation.height; y++) {
  -      index = x + simulation.width * y;
  -      <%= @simulation.soil.code.html_safe %>
  -    }
  -  }
  -<% for property in Soil::PROPERTIES %>
  -  postMessage({type: 'soil_data_layer_update', layer_name:'<%= property %>', layer_data: simulation.soil.<%= property %>});
  -<% end %>
  +	for(x = 0; x < simulation.width; x++) {
  +		for(y = 0; y < simulation.height; y++) {
  +			index = x + simulation.width * y;
  +			<%= @simulation.soil.code.html_safe %>
  +		}
  +	}
  +	<% for property in Soil::PROPERTIES %>
  +		postMessage({type: 'soil_data_layer_update', layer_name:'<%= property %>', layer_data: simulation.soil.<%= property %>});
  +	<% end %>
   }
   
   // Update the crops
   //------------------------------------------------------
   function updateCrops() {
  -  simulation.crops.forEach( function(crop) {
  -    for(x = 0; x < simulation.width; x++) {
  -      for(y = 0; y < simulation.height; y++) {
  -        crop_index = crop.id;
  -        patch_index = x + simulation.width * y;
  -        eval(crop.code);
  -      }
  -    }
  -  <% for property in Crop::PROPERTIES %>
  -    postMessage({type: 'crop_data_layer_update', crop_id: crop.id, layer_name: '<%= property %>', layer_data: simulation.crops[crop.id].<%= property %>});
  -  <% end %>
  -  });
  +	simulation.crops.forEach( function(crop) {
  +		for(x = 0; x < simulation.width; x++) {
  +			for(y = 0; y < simulation.height; y++) {
  +				crop_index = crop.id;
  +				patch_index = x + simulation.width * y;
  +				eval(crop.code);
  +			}
  +		}
  +		<% for property in Crop::PROPERTIES %>
  +			postMessage({type: 'crop_data_layer_update', crop_id: crop.id, layer_name: '<%= property %>', layer_data: simulation.crops[crop.id].<%= property %>});
  +		<% end %>
  +	});
   }
   
   //=====================================================
   // Simulation interaction methods
   
   function tillField(fieldIndex) {
  -  fields[fieldIndex]
  -
  +	fields[fieldIndex]
   }
   
   function plantFieldWithCrop(fieldIndex, cropID) {
  -  if(simulation.crops[cropID] == undefined) { // crop not already in use
  -
  -    // Load the crop data
  -    load('/crops/' + cropID + '.json', function(xhr) {
  -
  -      // create the crop
  -      simulation.crops[cropID] = JSON.parse(xhr.responseText);
  -    <% for property in Crop::PROPERTIES %>
  -      simulation.crops[cropID].<%= property %> = new Uint8Array(simulation.width * simulation.height);
  -    <% end %>
  -      postMessage({type: 'crop_initialize', crop_id: cropID, crop_name: simulation.crops[cropID].name});
  -
  -      // plant the crop
  -      simulation.fields[fieldIndex].patches.forEach( function(patch) {
  -        simulation.crops[cropID].root_biomass[patch.index] = 25 * patch.ratio
  -        simulation.crops[cropID].leaf_biomass[patch.index] = 25 * patch.ratio
  -      });
  -    <% for property in Crop::PROPERTIES %>
  -      postMessage({type: 'crop_data_layer_update', crop_id: cropID, layer_name: '<%= property %>', layer_data: simulation.crops[cropID].<%= property %>});
  -    <% end %>
  -
  -    });
  - 
  -
  -  } else {
  -
  -      // plant the crop
  -      simulation.fields[fieldIndex].patches.forEach( function(patch) {
  -        simulation.crops[cropID].root_biomass[patch.index] = 25 * patch.ratio
  -        simulation.crops[cropID].leaf_biomass[patch.index] = 25 * patch.ratio
  -      });
  -    <% for property in Crop::PROPERTIES %>
  -      postMessage({type: 'crop_data_layer_update', crop_id: cropID, layer_name: '<%= property %>', layer_data: simulation.crops[cropID].<%= property %>});
  -    <% end %>
  -
  -  }
  +	if (simulation.crops[cropID] == undefined) { // crop not already in use
  +
  +		// Load the crop data
  +		load('/crops/' + cropID + '.json', function(xhr) {
  +
  +			// create the crop
  +			simulation.crops[cropID] = JSON.parse(xhr.responseText);
  +			<% for property in Crop::PROPERTIES %>
  +				simulation.crops[cropID].<%= property %> = new Uint8Array(simulation.width * simulation.height);
  +			<% end %>
  +			postMessage({type: 'crop_initialize', crop_id: cropID, crop_name: simulation.crops[cropID].name});
  +
  +			// plant the crop
  +			simulation.fields[fieldIndex].patches.forEach( function(patch) {
  +				simulation.crops[cropID].root_biomass[patch.index] = 25 * patch.ratio
  +				simulation.crops[cropID].leaf_biomass[patch.index] = 25 * patch.ratio
  +			});
  +			<% for property in Crop::PROPERTIES %>
  +				postMessage({type: 'crop_data_layer_update', crop_id: cropID, layer_name: '<%= property %>', layer_data: simulation.crops[cropID].<%= property %>});
  +			<% end %>
  +		});
  +	}
  +	else {
  +		// plant the crop
  +		simulation.fields[fieldIndex].patches.forEach( function(patch) {
  +			simulation.crops[cropID].root_biomass[patch.index] = 25 * patch.ratio
  +			simulation.crops[cropID].leaf_biomass[patch.index] = 25 * patch.ratio
  +		});
  +		<% for property in Crop::PROPERTIES %>
  +			postMessage({type: 'crop_data_layer_update', crop_id: cropID, layer_name: '<%= property %>', layer_data: simulation.crops[cropID].<%= property %>});
  +		<% end %>
  +	}
   }
   
   <%= render "load_via_xhr" %>
  -<%= render "liang_barsky" %>
  +<%= render "liang_barsky" %>
positive.code: var index = 0
  <% for property in Soil::PROPERTIES %>
  function get_<%= property %>() {
    return simulation.soil.<%= property %>[index];
  }
  
  function set_<%= property %>(value) {
    simulation.soil.<%= property %>[index] = value;
  }
  <% end %>
  
  
negative.code: //  (2) tick messages, advancing the simulation, and
  //  (3) various agricultural operations carried out by the user, 
  //      such as planting
  
  //When we receive a message from the main thread
  onmessage = function(msg) {
  	switch(msg.data.type) {
  		case 'init':
  			initialize(simulation);
  			break;
  		case 'tick': 
  			simulation.clock.elapsed_time += 1; // Add one minute to elapsed time
  			simulation.clock.time += 60000; // Add one minute to time
  			update(simulation);
  			postMessage({type: 'time_update', time: simulation.clock.time});
  			break;
  		case 'till': 
  			tillField(msg.data.field);
  			break;
  		case 'plant':
  			plantFieldWithCrop(msg.data.field, msg.data.crop)
  			break;
  		case 'spray':
  			// do stuff
  			break;
  	}
  }
  
  //=====================================================
  // Simulation API
  
  window = {
  	alert: function(msg) { postMessage({type: 'alert', value: msg}) }
  }
  
  function get_elapsed_time() {
  	return simulation.clock.elapsed_time;
  }
  
  function get_simulation_year() {
  	return new Date(simulation.clock.time).getFullYear();
  }
  
  function get_simulation_month() {
  	// month is 0-indexed in JavaScript
  	return (new Date(simulation.clock.time).getMonth()) + 1;
  }
  
  function get_simulation_day_of_month() {
  	return new Date(simulation.clock.time).getDate();
  }
  
  function get_simulation_day_of_year() {
  	var startOfYear = new Date(new Date(simulation.clock.time).fullYear(), 0, 0);
  	// 1000 ms/s * 60 s/min * 60 min/hr * 24 hr/day = 86,400,000 ms/day
  	return Math.floor((simulation.clock.time - startOfyear)/86400000);
  }
  
  // Weather API
  <% for property in Weather::PROPERTIES %>
  function get_<%= property %>() {
  	return simulation.weather.<%= property %>;
  }
  
  function set_<%= property %>(value) {
  	simulation.weather.<%= property %> = value;
  }
  <% end %> 
  
  