Added some comments. Factored out the extra classes in rectangular.