added some tweaks from Dave