Some minor optimizations

In the case of singlefile this doesn't help much as the whole
implementation is algorithmically flawed. It's not like i care enough to
make the code even more complicated though.