Refactor. Split stuff out into separate files, make sure core doesn't depend on libuv