Initial implementation of the weighted layout, small fixes