Sorting BG code, fixed some resource conversion and loading.