* refactoring and fixes.