add ready event, better debugging
Merge branch 'patch-debug'