Bug fixes by Karnes