Several code quality tweaks