added more decoupling code; minor formatting