Code cleanup

Unused imports, missing stack traces in logging, resource handling issues and java doc issues fixed.