$decrement, $remove_thread and $remove_replies are useless variables. If you are not going to use them then just remove them from the code. OR if you need them, then just explain why do you need them.