Render markdown
Bugfixes to layout algorithm