+ Factored out the layout code
+ Added a strange hack to make UTF-8 work for the online version