ok the things that I can think of off of the top of my head that would cause this are
1- timing2- vacuum leak3- mafs4- AACV or AIV thing
#1 Set the motor to TDC on the compression stroke of #1 cylinder and then take out the distributor, line up the little mark thing and put it back in the motor. If that doesn't fix it move to step 2
#2 Go to a parts store and buy a cheap vacuum gauge thingy and hook it up, you should be pulling about 16 to 20 mm/hg at idle (assume about 900rpm) On the KA, there is a rats nest of vacuum hoses at the back of the engine that have a tendency to heat up and crack, totally fuxoring your idle. Check all those hoses and if that doesn't fix it, move to step 3
#3 Unplug the mafs, clean it with some carb cleaner, let it dry, clean the connections on the plugs with a toothbrush and some electrical parts cleaner and plug it back in. If that doesn't fix it move to step 4
#4 the air idle controller- It is the kinda big hose that connects to the plastic intake thingie right before the throttle body. in thory if you close that at idle, the car *should* die. if it makes no difference, then you have found the problem, if not, move to step 5
#5 Give me the car, cuz it is broken
I put them in order of probablility since to me it really seems like a timing or vacuum issue since it sucks and bogs at idle, but runs really well at higher RPM's I kinda don't think it is a MAFS problem because typically the exact opposite will occur. It will run perfectly fine at idle, but totally crap out at about 3 to 4k rpm I have dealt with MAFS problems on both SR and KA motors for a while now and I haven't seen any of them cause the car to be sluggish down low and fine up high, that just isn't how they "work" when they break.
Let us know how it goes, good luck to you.