Refactoring and some CSS fixes