Minor fixes, and code cleaning