added offline trees + some refactoring