mostly working. couple nits to fix. needs doc too.