Fix typos, reorganize definitions