code refactoring; fixes.