Refactor code of sphinx agent. Version 0.0.2