Repaired embed mode, some code clean-up