Here's a new version of these patches, rebased over current master. I squashed the two patches into one, there's not much point to keep them separate.
- Heikki