fixed static issues, and refactoring