fine tuning of layering code.