Actually working math-based layout