Refactoring torrent client

There should be no breaking changes; just extracted the code into modules. The next step would be to implement a better interface between the modules: currently they rely on `engine` as a _"global"_ object, mostly because of the events.