Some layout & minor js bugfixes

@jreinhardt I might have not seen all layout bugs so please tell me if you find more.