Fix some architectural issues