Fixed a critical bug affecting addLayer()