Bug fixes, improved errors and increased tracing printouts.