Bug fixes for Thomas