More bug fixes after testing on real use case.
More bug fixes after testing on real use case.