added pattern trees and some tests