Decouple backend and some clean up.