misc bug fixes noticed as integrating into large project.