Optimise and improve board queries and sorting

Does two things:

1) Breaks down BoardIndex query into three smaller queries, the sum of which is slightly faster than the single query. It breaks the moderator and moderator_group fetching code into separate queries

2) Explicitly sort boards everywhere, instead of relying on database table's sorted structure

Fixes SimpleMachines#858 and SimpleMachines#887 and maybe even SimpleMachines#1366