Implement statejoin & fix related bugs
Merge pull request #43 from c00w/join

Implement statejoin & fix related bugs