added stuff for feature extraction
some changes to work with patches