brought modified layers.py over from old working copy