Rewrote Topic.class.php and cleaned up the code