some refactoring and bugfixes.
css todo.