Small fixes + cleanup
(cherry picked from commit 61cba30)
(cherry picked from commit a20c015)