Prepares for allowing encryption at rest of resources as well as any other lower level optimization we might chose to implement. Also cleans up a bunch of ugly code.