Basically working Category tree now, but the code is ugly; there's got to be a better way...