Refactor attach to use HTTP and JSON, add client