Improved find function, bug fixes