Try to handle more special cases for #336.