refactorings
first working implementation with psi structure