Optimized Layout - added function + other fixes