Refactored code responsible for style management.

Also few other things were... uhm... improved.