Refactored operations to be a little more robust.