Fix a few bugs with layers and lines.