More work on decoupling and some bug fixes