Moved agent into separate module