Refactor daemon part to both suport synchronous and asynchronous Java NIO