Rewrote searching

Clean this mess up!