Cleanups + bug fixes.