 public extension BayaLayoutable {
     func layoutFlexibleContent(
         orientation: BayaLayoutOptions.Orientation,
-        before: BayaLayoutable?,
-        after: BayaLayoutable?,
+        before: BayaLayoutable? = nil,
+        after: BayaLayoutable? = nil,
         spacing: Int = 0,
         layoutMargins: UIEdgeInsets = UIEdgeInsets.zero)
             -> FlexibleContentLayout {

                    x: frame.minX + elements.before!.layoutMargins.left,
                    y: frame.minY + elements.before!.layoutMargins.top,
                    width: measures.before!.width,
                    height: frame.height - elements.before!.verticalMargins))
            }

            if elements.after != nil {
                elements.after!.layoutWith(frame: CGRect(
                    x: frame.minX + frame.width - measures.after!.width - elements.after!.layoutMargins.right,
                    y: frame.minY + elements.after!.layoutMargins.top,
                    width: measures.after!.width,
                    height: frame.height - elements.after!.verticalMargins))
            }

            let relevantBeforeWidth = elements.before?.widthWithMargins.add(spacing) ?? 0
            let relevantAfterWidth = elements.after?.widthWithMargins.add(spacing) ?? 0
            elements.content.layoutWith(frame: CGRect(
                x: frame.minX
                    + relevantBeforeWidth
                    + elements.content.layoutMargins.left,
                y: frame.minY + elements.content.layoutMargins.top,
                width: frame.width
                    - elements.content.horizontalMargins
                    - relevantBeforeWidth
                    - relevantAfterWidth,
                height: frame.height
                    - elements.content.verticalMargins))
        case .vertical:
            if elements.before != nil {
                elements.before!.layoutWith(frame: CGRect(
                    x: frame.minX + elements.before!.layoutMargins.left,
                    y: frame.minY + elements.before!.layoutMargins.top,
                    width: frame.width - elements.before!.horizontalMargins,
                    height: measures.before!.height))
            }

            if elements.after != nil {
                elements.after!.layoutWith(frame: CGRect(
                    x: frame.minX + elements.after!.layoutMargins.left,
                    y: frame.minY + frame.height - measures.after!.height - elements.after!.layoutMargins.bottom,
                    width: frame.width - elements.after!.horizontalMargins,
                    height: measures.after!.height))
            }

            let relevantBeforeHeight = elements.before?.heightWithMargins.add(spacing) ?? 0
            let relevantAfterHeight = elements.after?.heightWithMargins.add(spacing) ?? 0
            elements.content.layoutWith(frame: CGRect(
                x: frame.minX + elements.content.layoutMargins.left,
                y: frame.minY
                    + relevantBeforeHeight
                    + elements.content.layoutMargins.top,
                width: frame.width
                    - elements.content.horizontalMargins,
                height: frame.height
                    - elements.content.verticalMargins
                    - relevantBeforeHeight
                    - relevantAfterHeight))
        }
    }


            let relevantAfterWidth = afterWithMargins?.width.add(spacing) ?? 0
            let availableWidth = max(size.width - relevantBeforeWidth - relevantAfterWidth, 0)
            measures.content = elements.content.sizeThatFitsWithMargins(CGSize(width: availableWidth, height: size.height))
            let contentWithMargins = measures.content!.addMargins(ofElement: elements.content)
            return CGSize(
                width: relevantBeforeWidth + relevantAfterWidth + contentWithMargins.width,
                height: max(beforeWithMargins?.height ?? 0, afterWithMargins?.height ?? 0, contentWithMargins.height))

        case .vertical:
            let relevantBeforeHeight = beforeWithMargins?.height.add(spacing) ?? 0
            let relevantAfterHeight = afterWithMargins?.height.add(spacing) ?? 0
            let availableHeight = max(size.width - relevantBeforeHeight - relevantAfterHeight, 0)
            measures.content = elements.content.sizeThatFitsWithMargins(CGSize(width: size.width, height: availableHeight))
            let contentWithMargins = measures.content!.addMargins(ofElement: elements.content)
            return CGSize(
                width: max(beforeWithMargins?.width ?? 0, afterWithMargins?.width ?? 0, contentWithMargins.width),
                height: relevantBeforeHeight + relevantAfterHeight + contentWithMargins.height)
        }
    }
}
