Fixes and improvements

Code cosmetics.