Fixes to embedding code