Added custom layout functionality from Hybrid Core. Cleaned up some functions and updated  to work dynamically based on the layout width.