couple of JS code improvements
separated layout from hook
(pedantic JS changes)