Rewrote object creation code to be slightly more readable.