Tweaks and code cleanup