Some fixes
(cherry picked from commit 5b7de4b4d8209e6fc87b7bbb50de637d2ee7475d)