Fixing multiple issues and warnings