Added files to be written.
Fixed overall overhead. TODO: better rectangle selection when multiple rectangles are detected that are really close to each other. Better filtering in general. TO FIX: Calculations.