Minor bug fixes and formatting