Tiny fixes and code improvements