Fix warnings, code cleanup