fixes to enumerate. also move sample and factor into js header (since they can get k).