Fixes, cleanups, and some new utility functions...