Remove redundant code; complete implementation of Intelligent Agent