Updated based on some unexpected side effects.