some tweaks and bug fixes