Fixed warnings, minor code improvements