Add getLayerId convenience method
Fix some nasty bugs