Fixed issue with index of -1 when number of messages in thread is 0 by setting default values. Also fixed removal of empty threads so the threads with 0 messages should never even show up in the first place anymore.