Fix BitSet cast exception

This pull request appears to fix #42, but we should understand the cause more fully before merging it.