Fixed a bug that started occuring for me. It seemed that the order of determining the layout values was incorrect and causing issues.