Minor bug fixes and code consistency changes