updated to 3.4 and some refactoring