Collection of fixes: typos, formatting, logic