Bug fixes for cloning