Check for events before attaching 'ready' listener when adding a layer

Fixes #372