Refactoring to use BEM and some minor simplification.