Tweaks and code cleaning