multiple cases handling + various minor improvements