mass refactoring. added new stuff