40 gal? hmm
6-8 corys (12" if you got julii's or 20" if you got a 2.5" type cory -most are 2-2.5")
6-8 zebra danios or glofish(look at my sig pic - colorful danios) - that's 12-16"
1 clown pleco (i love these guys... great personality!) - 4-5"
or
1 BN pleco 4-5"
3 kuhli loaches.
You get a bunch of top action with the danios, great bottom/midlevel action with the corys, a good algae cleaner with either pleco, and good clean up crew with the kuhlis.
It's a heavy bottom crowd, so making various 'levels' in the tank would be great. This could be usng rocks or large ornaments such as large caves, pieces of
driftwood, etc.
You'll find the pleco either on the wood or on the glass, the corys rummaging all over everything looking for scraps (they love zucc/cucumber too - like the plecos would!), and the kuhlis do the same thing as the corys - except they hang from tall objects in the tank a lot.. making themselves part of the decoration. The glofish/danios are so active, they'd convince the others it's ok to come out and play! :0
That's what I would do for sure ;p