Add search animations and tidy up code