Update Task.java

Added the RPC mechanism. and cleaned out the code to make it more modular.