Refactor oembed layout code