major refactoring of style engine plus other changes