Refactor LFI and also fix a bug caused by changing category names.

NOTE: LFI really needs a serious overhaul next year.