Clean up the class building logic in OutputPage

Build the classes using an array that is finally imploded, instead of
concatenating strings repeatedly.

Change-Id: I2a09282d5ba33f131a4311c58e49dab5eefce418