multiple fixes

Eliminated all warnings, parameterized arguments, added logging, error
handling, cleaned up code, etc