Fix adapter. Steal tricks from @defunctzombie