Big import cleanup. Also removes context.context.thread

I really hope that Travis accepts this.