Fix warnings, change exceptions logic - a bit