Sort arrays correctly
Add relevant changes from server-conf branch