Changed structure of topic table and removed link caching to allow search links to work correctly

Fixed some warnings and notices about missing variables.