complete patch for #4279 and #3799

Signed-off-by: Aayush Anand <aayushism12@gmail.com>