[Code review] Fix various issues