Also about this: "Put nested classes next to the code that uses those classes. If the classes are intended to be used externally and aren't referenced inside the class, put them in the end, after the companion object." I would suggest to place nested classes on the end, just before companion objects.