More bug fixes and whitespace corrections