Bug fixes for problems with cycles