Fixing bug with elements and max height/width