Clean up duplicate code in styleguide lib