Fixed various compiler errors.

1. Also added lots of TRACE and LOG statements.  Perhaps too many.