Misc. bug fixes and comments