Fence optimization

+ implementing models (not finished)