Fixes and cleanups

Collection of small fixes, cleanups and improvements in various modules.