Refactoring GUI to use rpc. Not finished yet.