The docs are a bit sparing but if you read the source its pretty cool to see how they did this.