Revision that seems to work on WP8. Not extensively tested.