Implementing scratch registers correctly (I think).