Fix problem with branch selection and deletion of the first post in a topic

Couple of problems have been fixed:
-incorrect branch number in case of gaps in sequence of branch numbers (like 1,2,4,7).
-404 error in case of deletion a first post in a topic.