Moved common rendering code to base class, and added comments