Re recruiting generals: Just add the appropriate general unit to the recruit pool lines in export_descr_buildings.txt, along with. (Use the name from export_descr_units, such as NE Bodyguard for Northern European) I haven't done this personally, but I think this will create a "generals bodyguard" but no actual general.

Re Castle upkeep: Check out Foz's patcher here. Provided that a) a unit has the free upkeep attribute in export_descr_units.txt, and b) the settlement can recruit the unit, it can use an upkeep slot. So after using Foz's utility (or making the changes yourself), you'll be able to keep Mailed Knights at a Castle, and Town Militia in a city, but not vice versa.

Re Free Upkeep: Add a "free_upkeep bonus #" to whatever building you want to be add the upkeep slots. You'll need to do this for the castle upgrades levels, as well, if you want free upkeep in castles.