int CraftingSessionImplementation::clearSession() {
	Locker slocker(_this.get());

	ManagedReference<CraftingTool*> craftingTool = this->craftingTool.get();
	ManagedReference<CreatureObject*> crafter = this->crafter.get();
	ManagedReference<PlayerObject*> crafterGhost = this->crafterGhost.get();
	ManagedReference<CraftingStation*> craftingStation = this->craftingStation.get();
	ManagedReference<ManufactureSchematic*> manufactureSchematic = this->manufactureSchematic.get();
	ManagedReference<TangibleObject*> prototype = this->prototype.get();

	if (manufactureSchematic != NULL) {

		Locker locker(manufactureSchematic);

		if (manufactureSchematic->getParent() == craftingTool) {
			manufactureSchematic->setDraftSchematic(NULL);
			manufactureSchematic->cleanupIngredientSlots(crafter);
			manufactureSchematic->destroyObjectFromWorld(true);
		}

		this->manufactureSchematic = NULL;
	}

	if (craftingTool != NULL) {
		Locker locker2(craftingTool);

		// Remove all items that aren't the prototype
		while (craftingTool->getContainerObjectsSize() > 1) {
			craftingTool->getContainerObject(1)->destroyObjectFromWorld(true);
		}

		craftingTool->dropSlottedObject("crafted_components");

		if (prototype != NULL) {

			Locker locker3(prototype);

			if (craftingTool->isReady()) {

				if (prototype->getParent() == craftingTool) {
					prototype->destroyObjectFromWorld(true);
				}

				this->prototype = NULL;
			}
		}
	}

	if(crafterGhost != NULL && crafterGhost->getDebug()) {
		crafter->sendSystemMessage("*** Clearing crafting session ***");
	}

	return 0;
}