Fixed various oversights, updated some comments and formatting, etc.