Mostly working code, although the search section still needs a little work.