Fixed bugs in adapter.py