Added topic stuff and cleaned up some code