Adding a simple model for cancellation
Some refactorings and laying the groundwork for letting threads requests be interrupted from the client.