Fixed some warnings, code cleanup